<?php

/**
 * this class provides working with submenus
 * @author		ungerboeck simon <su@militaerversand.at>
 *
 */
class SubMenu {
    private $id;
    private $style;
    private $buttons = array();

    /************************************************************************
     ************************** PUBLIC FUNCTIONS ****************************
     ************************************************************************/

    /**
     * sets the id. if id is not given use a unique id
     * @param         string         $id
     */
    public function __construct($id = null) {
        $id = (isset($id) ? $id : uniqid());
        $this->id = $id;
    }


    /**
     * adds a normal button to the button array
     * @param         mixed         $button
     */
    public function addButton($button) {
        array_push($this->buttons, $button);
    }


    /**
     * creates the whole submenu
     * @return         string        $output
     */
    public function create() {
        $output = '<div id="' . $this->id . '">';
        foreach ($this->buttons as $button)
            $output .= $button->create();
        $output .= '</div>';
        return $output;
    }


    /************************************************************************
     **************************** GETTER / SETTER ***************************
     ************************************************************************/

    public function setId($id) {
        $this->id = $id;
    }

    public function setStyle($style) {
        $this->style = $style;
    }


    public function getId() {
        return $this->id;
    }


    public function getStyle() {
        return $this->style;
    }


    /************************************************************************
     ************************** PRIVATE FUNCTIONS ***************************
     ************************************************************************/
}